libxc: don't populate same pfn more than once in populate_pfns
authorWei Liu <wei.liu2@citrix.com>
Sun, 6 Sep 2015 20:05:38 +0000 (21:05 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 7 Sep 2015 10:54:30 +0000 (11:54 +0100)
commite8e9f830dc46ea2bad6919af1fdffc136dfb3aeb
tree2d45e6d74853d29b5426a36913816819f42ff532
parente00f8a1a75dfb1c0ce33752e4a284fc0af3e0cf3
libxc: don't populate same pfn more than once in populate_pfns

The original implementation of populate_pfns didn't consider the same
pfn can be present multiple times in the array. The mechanism to prevent
populating the same pfn multiple times only worked if the recurring pfn
appeared in different batches.

This bug is discovered by Linux 4.1 32 bit kernel save / restore test,
which has several ptes pointing to same pfn, which results in an array
containing recurring pfn.  When libxc called x86_pv_localise_page, the
original implementation would populate the same pfn more than once.

The fix is to set bit in populated bitmap as we generate list of pfns to
be populated.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxc/xc_sr_restore.c